/**
 * 在stestjs的版本这个你去除对express的依赖
 */
var http = require('http');
var httpServer = http.createServer();
var server = require('socket.io')(httpServer);
var port = process.env.PORT || 3000;
var clientList = new Set();
server.on('connection', function(socket) {
    //接受消息
    socket.id = clientList.size + 1;
    console.log("链接信息是2：",socket.id);
    clientList.add(socket);
    socket.on('message', function (msg) {
        console.log('server1 receive messge223 : ' + msg,new Date() );
        socket.emit('message', {msg:msg,time:new Date()});
    });
    
    //发送消息
    socket.emit('message', 'hello from server2');

    //断开连接回调--客户端断开连接
    socket.on('disconnect', function () { 
        //通知其他用户
        clientList.delete(socket);
        console.log('socket disconnect');
    });
});



httpServer.listen(port, function () {
    console.log('inewhome tool sk port %d', port);
});